<template>
<view class="content">
	<view class="box">
		<view class="logo">
			<image src='http://codegen.caihongy.cn/20220212/ad27dde95af143db9a6447f869150241.jfif' mode="aspectFill"></image>
			<view class="title">找回密码</view>
		</view>
		<view class="form-item">
			<input v-model="username" type="text" class="input" placeholder="请输入您的账号" />
		</view>
		<view class="form-item">
			<picker @change="optionsChange" :value="index" :range="options">
				<view class="picker-view">{{options[index]}}</view>
			</picker>
		</view>
		<button class="btn-submit" @tap="onResetPass" type="primary">重置密码</button>
		<view class="links">
			<view class="link-item" @tap="goLogin">返回登录</view>
		</view>
	</view>
</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				options: [
                    '请选择登陆用户类型',
					'用户',
                ],
                optionsValues: [
					'',
					'yonghu',
				],
				index: 0
			}
		},
		onLoad() {
			this.styleChange()
		},
		methods: {
			async onResetPass() {
				if(this.username==undefined) {
					this.$utils.msg('请输入账号')
					return;
                }
				if(this.optionsValues[this.index]=="") {
					this.$utils.msg('请选择角色')
                    return;
				}
				let res = await this.$api.resetPass(`${this.optionsValues[this.index]}`, this.username)
				this.$utils.msgBack("重置密码成功,原始密码为:123456")
			},
			optionsChange(e) {
				this.index = e.target.value
			},
			styleChange() {
				this.$nextTick(()=>{
					// document.querySelectorAll('.forget-input .uni-input-input').forEach(el=>{
					//   el.style.backgroundColor = this.restPwFrom.content.input.backgroundColor
					// })
				})
			},
			goLogin() {
				this.$utils.jump('../login/login')
			}
		}
	}
</script>

<style lang="scss" scoped>
	$color-primary: #4A4A4A;

	.content {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		height: 100vh;
		box-sizing: border-box;
		background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
	}
	
	.box {
		padding: 60rpx 40rpx;
		box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.1);
		margin: 0 5%;
		background-color: rgba(255, 255, 255, 0.95);
		border-radius: 24rpx;
		width: 90%;
		max-width: 600rpx;
	}
	
	.logo {
		padding: 0;
		margin: 0 0 60rpx;
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		
		image {
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
		}
		
		.title {
			margin-top: 20rpx;
			font-size: 36rpx;
			font-weight: bold;
			color: $color-primary;
		}
	}
	
	.form-item {
		margin-bottom: 30rpx;
		
		.input {
			padding: 0 30rpx;
			background-color: #f8f8f8;
			color: #333;
			border-radius: 12rpx;
			width: 100%;
			height: 88rpx;
			font-size: 28rpx;
			box-sizing: border-box;
			border: 1px solid #eee;
		}
		
		.picker-view {
			padding: 0 30rpx;
			background-color: #f8f8f8;
			color: #333;
			border-radius: 12rpx;
			width: 100%;
			height: 88rpx;
			line-height: 88rpx;
			font-size: 28rpx;
			box-sizing: border-box;
			border: 1px solid #eee;
		}
	}
	
	.btn-submit {
		background-color: $color-primary;
		border-radius: 12rpx;
		color: #fff;
		width: 100%;
		font-size: 32rpx;
		height: 88rpx;
		line-height: 88rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
		transition: all 0.3s ease;
		
		&:active {
			transform: scale(0.98);
			opacity: 0.9;
		}
	}
	
	.links {
		margin-top: 40rpx;
		display: flex;
		justify-content: center;
		
		.link-item {
			padding: 20rpx 0;
			color: $color-primary;
			font-size: 26rpx;
		}
	}
</style>
